public class Demo1 {
    public static void main(String[] args) {
        Object locker = new Object();
        Thread t1 = new Thread(()->{
            synchronized (locker){
                System.out.println("t1执行到wait之前");
                try {
                    locker.wait();
                    System.out.println("t1被唤醒");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        Thread t2 = new Thread(()->{
            synchronized (locker){
                System.out.println("t2执行到wait之前");
                try {
                    locker.wait();
                    System.out.println("t2被唤醒");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        Thread t3 = new Thread(()->{
            synchronized (locker){
               locker.notify();
            }
        });
        t1.start();
        t2.start();
        t3.start();
    }
}
